function [value] = lin_interpo2(nx,ny,gridx,gridy,v,x,y)
    
    widthx=gridx(2)-gridx(1);
    widthy=gridy(2)-gridy(1);
    
    minx=gridx(1);
    miny=gridy(1);
    maxx=gridx(nx);
    maxy=gridy(ny);
    
    position_x=floor((x-minx)/widthx)+1;
    position_y=floor((y-miny)/widthy)+1;
    
    position_x=max(position_x,1);
	position_x=min(position_x,nx-1);
	position_y=max(position_y,1);
	position_y=min(position_y,ny-1);

	weightx1=(x-gridx(position_x))/widthx;
	weightx2=1-weightx1;

	value1=weightx1*v(position_x+1,position_y)+weightx2*v(position_x,position_y);
	value2=weightx1*v(position_x+1,position_y+1)+weightx2*v(position_x,position_y+1);

	weighty1=(y-gridy(position_y))/widthy;
	weighty2=1-weighty1;
	value=weighty1*value2+weighty2*value1;


end

